package exercises;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Map;

public class CountWords2 {
    public static void main(String[] args) throws IOException {
        // 获取开始时间
        long startTime = System.currentTimeMillis();
//        String filePath = "resource/CountWordsBig.txt";
//        String filePath = "resource/CountWords.txt.txt";
        String filePath = "resource/CountWordsLittle.txt";
        FileDeal fileDeal = new FileDeal(filePath);
//        FileDealV2 fileDeal = new FileDealV2(filePath);
        // 判断文件是否合法
        if (!fileDeal.inspectFile()){
            System.out.println("文件不存在或文件是目录或空文件！");
        }
        else{
            // 读取并处理文件
            Map map = fileDeal.dealFile();
            // 输出
            fileDeal.outPut(map);
        }
        // 获取结束时间
        long endTime = System.currentTimeMillis();
        System.out.println("程序运行时间： " + (endTime - startTime) + "ms");
    }
}
